/*
 * Created by seeker910 on 2015/5/29.
 */

Rsd.define('Rsd.Faith.pages.FiscalKaiFaShangJiaoCunListPage', {
    extend: 'Rsd.Faith.pages.ListPage',
    requires: [ 'Rsd.Faith.controls.XiaoQuInput', 'Rsd.controlEx.ComboBoxEnum','Rsd.Faith.controls.SuoShuQiInput'],
    xtype: 'list-kaifashang-shenqing',
    border: false,
    tabTitle: '住房维修资金缴存信息',
    searchColumns:[
        {name:'SuoShuQi',text:'所属期',width:200,xtype:'ctrl-suoshuqi'},
        {name:'ShenQingBianHao',text:'申请编号',width:250},
        {name:'XiaoQuBianHao',text:'楼栋编号',width:200},
        {name:'ShangShiBianHao',text:'上市楼宇编号',width:250},
        {name:'KaiFaShangMingCheng',text:'开发商名称',width:200},
        {name:'ZhuangTai',text:'状态',width:150, "xtype": "combobox-enum", "enum":"Rsd.Faith.Core.KaiFaShangJiaoCunZhuangTai"}
    ],
    newButtons:[{text:'新增交存申请',handler:'newItem'}],
    modelType: 'FiscalKaiFaShangJiaoCunShenQingModel',
    readOnly:false,
    formFields: [
        {
            "name": "ShenQingBianHao",
            "label": {
                "width": 80,
                "content": "申请编号"
            },
            "dataIndex": "ShenQingBianHao",
            "index": 20,
            "exist": true,
            "xtype": "text",
            "length": 20
        },
        {
            "name": "XiaoQuBianHao",
            "label": {
                "width": 80,
                "content": "小区编号"
            },
            "dataIndex": "XiaoQuBianHao",
            "index": 22,
            "exist": true,
            "xtype": 'ctrl-xiaoqu',
            "length": 20
        },
        {
            "name": "LouDongBianHao",
            "label": {
                "width": 80,
                "content": "楼栋编号"
            },
            "dataIndex": "LouDongBianHao",
            "index": 24,
            "exist": true,
            "xtype": "text",
            "length": 20
        },
        {
            "name": "ShangShiBianHao",
            "label": {
                "width": 80,
                "content": "上市楼宇编号"
            },
            "dataIndex": "ShangShiBianHao",
            "index": 26,
            "exist": true,
            "xtype": "text",
            "length": 20
        },
        {
            "name": "LouDongHao",
            "label": {
                "width": 80,
                "content": "楼栋号"
            },
            "dataIndex": "LouDongHao",
            "index": 28,
            "exist": true,
            "xtype": "text",
            "length": 250
        },
        {
            "name": "SuoZaiQu",
            "label": {
                "width": 80,
                "content": "所在区"
            },
            "dataIndex": "SuoZaiQu",
            "index": 30,
            "exist": true,
            "xtype": "text",
            "precision": 0
        },
        {
            "name": "DiZhi",
            "label": {
                "width": 80,
                "content": "地址"
            },
            "dataIndex": "DiZhi",
            "index": 32,
            "exist": true,
            "xtype": "text",
            "length": 120
        },
        {
            "name": "KaiFaShangBianHao",
            "label": {
                "width": 80,
                "content": "开发商编号"
            },
            "dataIndex": "KaiFaShangBianHao",
            "index": 34,
            "exist": true,
            "xtype": "text",
            "length": 10
        },
        {
            "name": "KaiFaShangMingCheng",
            "label": {
                "width": 80,
                "content": "开发商名称"
            },
            "dataIndex": "KaiFaShangMingCheng",
            "index": 36,
            "exist": true,
            "xtype": "text",
            "length": 10
        },
        {
            "name": "ZongCengShu",
            "label": {
                "width": 80,
                "content": "总层数"
            },
            "dataIndex": "ZongCengShu",
            "index": 38,
            "exist": true,
            "xtype": "number",
            "precision": 0
        },

        {
            "name": "DiMianCengShu",
            "label": {
                "width": 80,
                "content": "地面层数"
            },
            "dataIndex": "DiMianCengShu",
            "index": 40,
            "exist": true,
            "xtype": "number",
            "precision": 0
        },
        {
            "name": "YouDianTi",
            "label": {
                "width": 80,
                "content": "是否有电梯"
            },
            "dataIndex": "YouDianTi",
            "index": 39,
            "exist": true,
            "xtype": "number",
            "precision": 0
        },
        {
            "name": "ZongHuShu",
            "label": {
                "width": 80,
                "content": "总户数"
            },
            "dataIndex": "ZongHuShu",
            "index": 42,
            "exist": true,
            "xtype": "text",
            "length": 256
        },
        {
            "name": "ZongMianJi",
            "label": {
                "width": 80,
                "content": "总面积"
            },
            "dataIndex": "ZongMianJi",
            "index": 44,
            "exist": true,
            "xtype": "number",
            "precision": 2
        },
        {
            "name": "YingJiaoJinE",
            "label": {
                "width": 80,
                "content": "应交金额"
            },
            "dataIndex": "YingJiaoJinE",
            "index": 46,
            "exist": true,
            "xtype": "number",
            "precision": 2
        },
        {
            "name": "JinEDaXie",
            "label": {
                "width": 80,
                "content": "金额大写"
            },
            "dataIndex": "JinEDaXie",
            "index": 48,
            "exist": true,
            "xtype": "text",
            "length": 256
        },
        {
            "name": "SuoShuQi",
            "label": {
                "width": 80,
                "content": "入账所属期"
            },
            "dataIndex": "SuoShuQi",
            "index": 50,
            "exist": true,
            "xtype": "text",
            "length": 20
        },
        {
            "name": "JiaoNaRiQi",
            "label": {
                "width": 80,
                "content": "交纳日期"
            },
            "dataIndex": "JiaoNaRiQi",
            "index": 52,
            "exist": true,
            "xtype": "date",
            "formatString": "yyyy-MM-dd"
        },
        {
            "name": "ZhuangTai",
            "label": {
                "width": 80,
                "content": "状态"
            },
            "dataIndex": "ZhuangTai",
            "index": 54,
            "exist": true,
            "xtype": "combobox-enum",
            "enum":  "Rsd.Faith.Core.KaiFaShangJiaoCunZhuangTai"
        },
        {
            "name": "Remark",
            "label": {
                "width": 80,
                "content": "备注"
            },
            "dataIndex": "Remark",
            "index": 200,
            "exist": true,
            "xtype": "text",
            "length": 100
        }
    ],
    sort:[{name:'ShenQingBianHao',direction:'desc'}],
    gridColumns:  [
        {
            "text": "序号",
            "xtype": "index",
            "width": 40,
            "index": 0
        },
        {
            "name": "ShenQingBianHao",
            "dataIndex": "ShenQingBianHao",
            "sortable": false,
            "text": "申请编号",
            "index": 20,
            "exist": true,
            "xtype": "string",
            "width": 150,
             format:'format_bianhao',
            "nobr": false
        },
        {
            "name": "ZhuangTai",
            "dataIndex": "ZhuangTai",
            "sortable": false,
            "text": "状态",
            "index": 54,
            "exist": true,
            "xtype": "enum",
            "enum": {
                "name": "Rsd.Faith.Core.KaiFaShangJiaoCunZhuangTai",
                "valueMember": "code",
                "textMember": "text",
                "items": [
                    {
                        "code": "DJ",
                        "value": 0,
                        "text": "已登记,待审核"
                    },
                    {
                        "code": "TG",
                        "value": 1,
                        "text": "审核通过"
                    },
                    {
                        "code": "JJ",
                        "value": 2,
                        "text": "审核不通过"
                    },
                    {
                        "code": "YJ",
                        "value": 2,
                        "text": "已交款,待确认"
                    },
                    {
                        "code": "RZ",
                        "value": 3,
                        "text": "已确认入账"
                    }
                ]
            },
            "width": 120,
            "nobr": true
        },
        {
            "name": "XiaoQuBianHao",
            "dataIndex": "XiaoQuBianHao",
            "sortable": false,
            "text": "小区编号",
            "index": 22,
            "exist": true,
            "xtype": "ctrl-xiaoqu",
            "width": 100,
            "nobr": true
        },
        {
            "name": "LouDongBianHao",
            "dataIndex": "LouDongBianHao",
            "sortable": false,
            "text": "楼栋编号",
            "index": 24,
            "exist": true,
            "xtype": "string",
            "width": 100,
            "nobr": true
        },
        {
            "name": "ShangShiBianHao",
            "dataIndex": "ShangShiBianHao",
            "sortable": false,
            "text": "上市楼宇编号",
            "index": 26,
            "exist": true,
            "xtype": "string",
            "width": 100,
            "nobr": true
        },
        {
            "name": "LouDongHao",
            "dataIndex": "LouDongHao",
            "sortable": false,
            "text": "楼栋号",
            "index": 28,
            "exist": true,
            "xtype": "string",
            "width": 70,
            "nobr": true
        },
        {
            "name": "SuoZaiQu",
            "dataIndex": "SuoZaiQu",
            "sortable": false,
            "text": "所在区",
            "index": 30,
            "exist": true,
            "xtype": "string",
            "width": 100,
            "precision": 0
        },
        {
            "name": "DiZhi",
            "dataIndex": "DiZhi",
            "sortable": false,
            "text": "地址",
            "index": 32,
            "exist": true,
            "xtype": "string",
            "width": 150,
            "nobr": true
        },
        {
            "name": "KaiFaShangBianHao",
            "dataIndex": "KaiFaShangBianHao",
            "sortable": false,
            "text": "开发商编号",
            "index": 34,
            "exist": true,
            "xtype": "string",
            "width": 100,
            "nobr": true
        },
        {
            "name": "KaiFaShangMingCheng",
            "dataIndex": "KaiFaShangMingCheng",
            "sortable": false,
            "text": "开发商名称",
            "index": 36,
            "exist": true,
            "xtype": "string",
            "width": 100,
            "nobr": true
        },
        {
            "name": "ZongCengShu",
            "dataIndex": "ZongCengShu",
            "sortable": false,
            "text": "总层数",
            "index": 38,
            "exist": true,
            "xtype": "number",
            "width": 60,
            "precision": 0
        },
        {
            "name": "DiMianCengShu",
            "dataIndex": "DiMianCengShu",
            "sortable": false,
            "text": "地面层数",
            "index": 40,
            "exist": true,
            "xtype": "number",
            "width": 60,
            "precision": 0
        },
        {
            "name": "YouDianTi",
            "dataIndex": "YouDianTi",
            "sortable": false,
            "text": "有电梯",
            "index": 39,
            "exist": true,
            "xtype": "number",
            "width": 60,
            "precision": 0
        },
        {
            "name": "ZongHuShu",
            "dataIndex": "ZongHuShu",
            "sortable": false,
            "text": "总户数",
            "index": 42,
            "exist": true,
            "xtype": "string",
            "width": 60,
            "nobr": true
        },
        {
            "name": "ZongMianJi",
            "dataIndex": "ZongMianJi",
            "sortable": false,
            "text": "总面积",
            "index": 44,
            "exist": true,
            "xtype": "number",
            "width": 100,
            "precision": 2
        },
        {
            "name": "YingJiaoJinE",
            "dataIndex": "YingJiaoJinE",
            "sortable": false,
            "text": "应交金额",
            "index": 46,
            "exist": true,
            "xtype": "number",
            "width": 100,
            "precision": 2
        },
        {
            "name": "JinEDaXie",
            "dataIndex": "JinEDaXie",
            "sortable": false,
            "text": "金额大写",
            "index": 48,
            "exist": true,
            "xtype": "string",
            "width": 150,
            "nobr": true
        },
        {
            "name": "SuoShuQi",
            "dataIndex": "SuoShuQi",
            "sortable": false,
            "text": "入账所属期",
            "index": 50,
            "exist": true,
            "xtype": "string",
            "width": 80,
            "nobr": true
        },
        {
            "name": "JiaoNaRiQi",
            "dataIndex": "JiaoNaRiQi",
            "sortable": false,
            "text": "交纳日期",
            "index": 52,
            "exist": true,
            "xtype": "date",
            "formatString": "yyyy-MM-dd",
            "width": 100,
            "precision": 3
        },

        {
            "name": "Remark",
            "dataIndex": "Remark",
            "sortable": false,
            "text": "备注",
            "index": 200,
            "exist": true,
            "xtype": "string",
            "width": 100,
            "nobr": true
        }
    ],
    titleField : 'FaPiaoBianHao',
    /*
     * */
    constructor: function (config) {
        config = config || {};
        Rsd.apply(this, config);
    },
    /*
    * */
    format_bianhao:function (row) {
        var  btn = document.createElement('a');
        btn.href='#';
        btn.innerHTML = '查看详情';
        $(btn).click (function(){
            Rsd.create('Rsd.Faith.dialogs.FiscalKaiFangShangJiaoCunDialog',{data:row}).showDialog();
        } );

        if(row["ZhuangTai"]=="DJ")
        {
            return [btn,Rsd.newLine(),Rsd.btn('审核',function () {
                Rsd.alert('通过或不通过');
            })];
        }
        if(row["ZhuangTai"]=="TG")
        {
            return [btn,Rsd.newLine(),Rsd.btn('打印交款通知',function () {
                var key = 'TZ_' + row['Id'];
                var _data={
                    barcode:'9780199532179',
                    KFS:'恒大房地产开发公司',
                    FWDM:'0000000000',
                    XZQY:'三茅',
                    JKLX:'补交',
                    DZ:'扬中市三茅中电路281号',
                    ZCS:30,
                    DSCS:30,
                    SZLC:12,
                    JZMJ:'120m²',
                    LDH:'20幢/塔楼A',
                    SH:'102',
                    JCBZ:'40元/平方米',
                    YZXM:'张三',
                    WQBH:'123456789012345',
                    SFZH:'3200000000000000000',
                    BJJE:Rsd.formatCurrency(3600,'¥'),
                    JEDX:Rsd.formatCurrencyCN(3600),
                    JZDW:'镇江市物业管理中心',
                    TBRQ:new Date().format('yyyy-MM-dd'),
                    DYRQ:new Date().format('yyyy-MM-dd')
                };
                Rsd.writeSession(key,_data);
                window.open('print.html?tpl=ShouCiJiaoCunTongZhiDan&key='+key);
            }),
                Rsd.btn('已交存',function () {
                    Rsd.alert('填写转账流水,上传转账凭证(回单)');
            })];
        }
        if(row["ZhuangTai"]=="YJ")
        {
            return [btn,Rsd.newLine(),Rsd.btn('确认入账',function () {
                Rsd.alert('人工确认,或同步银行流水');
            })];
        }
        if(row["ZhuangTai"]=="RZ")
        {
            return [btn,Rsd.newLine(),
                Rsd.btn('打印清册',function () {
                var _data = {
                    barcode:'9780199532179',
                    KFS:'恒大房地产开发公司',
                    XZQY:'三茅',
                    ZCS:31,
                    DSCS:30,
                    ZHS:60,
                    ZMJ:7200,
                    KHH:'中国银行',
                    HM:'扬中市维修资金管理中心',
                    ZH:'88888888888888888',
                    DZ:'扬中市三茅中电路281号',
                    XQBH:'23000',
                    LDBH:'88888888888',
                    LDH:'20幢/塔楼A',
                    LYBH:'32000000000',
                    DT:'无电梯',
                    YJJE:Rsd.formatCurrency(3600,'¥'),
                    JEDX:Rsd.formatCurrencyCN(3600),
                    JZDW:'镇江市物业管理中心',
                    TBRQ:new Date().format('yyyy-MM-dd'),
                    DYRQ:new Date().format('yyyy-MM-dd'),
                    fangWuList:[
                        {FWDM:'0000000001',SH:'101',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000002',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000003',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000004',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000005',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000006',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000007',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000008',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000009',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000010',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000011',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000012',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000013',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000014',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000015',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000016',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000017',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000018',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000019',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'},
                        {FWDM:'0000000020',SH:'102',MJ:'120',JCBZ:'40元/平方米',JCJE:'4800.00'}


                    ]
                };
                var key = 'QC_' + row['Id'];
                Rsd.writeSession(key,_data);
                window.open('print.html?tpl=LouDongJiaoCunQingChe&key='+key);
            }),
                Rsd.btn('打印回单',function () {
                    var _data = {
                        KFS:'恒大房地产开发公司',
                        LPMC:'晶地翡丽',
                        XZQY:'三茅',
                        ZCS:31,
                        DSCS:30,
                        ZHS:60,
                        ZMJ:7200,
                        DZ:'扬中市三茅中电路281号',
                        LDBH:'88888888888',
                        LDH:'20幢/塔楼A',
                        YJJE:Rsd.formatCurrency(3600,'¥'),
                        JEDX:Rsd.formatCurrencyCN(3600),
                        TBRQ:new Date().format('yyyy-MM-dd'),
                        DYRQ:new Date().format('yyyy-MM-dd'),
                        JBR:'张三',
                        SKDW:'扬中市住宅专项维修资金管理中心',
                        SKYH:'中国银行扬中分行'

                    };
                    var key = 'HD_' + row['Id'];
                    Rsd.writeSession(key,_data);
                    window.open('print.html?tpl=LouDongJiaoCunHuiDan&key='+key);
                }),
                Rsd.btn('打印证明',function () {
                    var _data = {
                        KFS:'恒大房地产开发公司',
                        LPMC:'晶地翡丽',
                        XZQY:'三茅',
                        ZCS:31,
                        DSCS:30,
                        ZHS:60,
                        ZMJ:7200,
                        DZ:'扬中市三茅中电路281号',
                        LDBH:'88888888888',
                        LDH:'20幢/塔楼A',
                        JCJE:Rsd.formatCurrency(3600,'¥'),
                        JEDX:Rsd.formatCurrencyCN(3600),
                        TBRQ:new Date().format('yyyy-MM-dd'),
                        DYRQ:new Date().format('yyyy-MM-dd'),
                        JBR:'张三',
                        SKDW:'扬中市住宅专项维修资金管理中心',
                        SKYH:'中国银行扬中分行'

                    };
                    var key = 'ZM_' + row['Id'];
                    Rsd.writeSession(key,_data);
                    window.open('print.html?tpl=LouDongJiaoCunZhengMing&key='+key);
                })];
        }
    }

});